<?php
namespace app\admin\controller;

use think\Controller;
use think\Session;
use think\Db;

/**
 * 自定义基层类
 */
class Base extends Controller
{
    protected $admin_id,$user_name,$real_name;

    /**
     * 构造方法
     */
    public function __construct()
    {
        parent::__construct();

        // 验证是否登陆
        Session::get('admin_id')    == null || $this->admin_id  = Session::get('admin_id');
        Session::get('user_name')   == null || $this->user_name = Session::get('user_name');
        Session::get('real_name')   == null || $this->real_name = Session::get('real_name');

        // 跳转登陆页面
        if($this->admin_id<=0){
            $this->redirect("login/index");
        }

        // 输出用户信息
        $this->assign('user_info',$this->user_info($this->admin_id));


    }


    /**
     * 用户信息
     */
    public function user_info($admin_id)
    {
        // 实例化admin模型类
        $model = Model('admin');

        // 条件
        $model->B_where = ['id'=>$admin_id];

        return $model->getOne();

    }

}
